Skip to content

[FLINK-37669][HELM] Add Helm chart unit tests to flink kubernetes operator #971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ChenYi015
Copy link

@ChenYi015 ChenYi015 commented Apr 14, 2025

What is the purpose of the change

(For example: This pull request adds a new feature to periodically create and maintain savepoints through the FlinkDeployment custom resource.)

Add Helm chart unit tests to flink kubernetes operator, see helm-unittest.

Brief change log

  • Reorganize the Helm chart directory
  • Add Helm chart unit tests
  • Update .helmignore to ingore helm unit test files
$ # Before
$ tree helm/flink-kubernetes-operator  
helm/flink-kubernetes-operator
├── Chart.yaml
├── conf
│   ├── flink-conf.yaml
│   ├── log4j-console.properties
│   └── log4j-operator.properties
├── crds
│   ├── flinkdeployments.flink.apache.org-v1.yml
│   ├── flinksessionjobs.flink.apache.org-v1.yml
│   └── flinkstatesnapshots.flink.apache.org-v1.yml
├── templates
│   ├── _helpers.tpl
│   ├── flink-operator.yaml
│   ├── rbac.yaml
│   ├── serviceaccount.yaml
│   └── webhook.yaml

$ # After
helm/flink-kubernetes-operator
├── Chart.yaml
├── conf
│   ├── flink-conf.yaml
│   ├── log4j-console.properties
│   └── log4j-operator.properties
├── crds
│   ├── flinkdeployments.flink.apache.org-v1.yml
│   ├── flinksessionjobs.flink.apache.org-v1.yml
│   └── flinkstatesnapshots.flink.apache.org-v1.yml
├── templates
│   ├── _helpers.tpl
│   ├── certmanager
│   │   ├── _helpers.tpl
│   │   ├── certificate.yaml
│   │   └── issuer.yaml
│   ├── controller
│   │   ├── _helpers.tpl
│   │   ├── configmap.yaml
│   │   └── deployment.yaml
│   ├── flink
│   │   ├── _helpers.tpl
│   │   ├── role.yaml
│   │   └── role_binding.yaml
│   ├── rbac
│   │   ├── _helpers.tpl
│   │   ├── cluster_role.yaml
│   │   ├── cluster_role_binding.yaml
│   │   ├── role.yaml
│   │   ├── role_binding.yaml
│   │   └── service_account.yaml
│   └── webhook
│       ├── _helpers.tpl
│       ├── mutating_webhook_configuration.yaml
│       ├── secret.yaml
│       ├── service.yaml
│       └── validating_webhook_configuration.yaml
├── tests
│   ├── certmanager
│   │   ├── certificate_test.yaml
│   │   └── issuer_test.yaml
│   ├── controller
│   │   ├── configmap_test.yaml
│   │   └── deployment_test.yaml
│   ├── flink
│   │   ├── role_binding_test.yaml
│   │   └── role_test.yaml
│   ├── rbac
│   │   ├── cluster_role_binding_test.yaml
│   │   ├── cluster_role_test.yaml
│   │   ├── role_binding_test.yaml
│   │   └── role_test.yaml
│   └── webhook
│       ├── mutating_webhook_configuration_test.yaml
│       ├── secret_test.yaml
│       ├── service_test.yaml
│       └── validating_webhook_configuratioin_test.yaml

Verifying this change

This change added tests and can be verified as follows:

$ helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1

$ helm unittest helm/flink-kubernetes-operator --file "tests/**/*_test.yaml" --strict --debug

### Chart [ flink-kubernetes-operator ] helm/flink-kubernetes-operator

 PASS  Test Cert Manager Certificate    helm/flink-kubernetes-operator/tests/certmanager/certificate_test.yaml
 PASS  Test Cert Manager Issuer helm/flink-kubernetes-operator/tests/certmanager/issuer_test.yaml
 PASS  Test ConfigMap   helm/flink-kubernetes-operator/tests/controller/configmap_test.yaml
 PASS  Test Deployment  helm/flink-kubernetes-operator/tests/controller/deployment_test.yaml
 PASS  Test Flink Job RoleBinding       helm/flink-kubernetes-operator/tests/flink/role_binding_test.yaml
 PASS  Test Flink Job Role      helm/flink-kubernetes-operator/tests/flink/role_test.yaml
 PASS  Test Operator ClusterRoleBinding helm/flink-kubernetes-operator/tests/rbac/cluster_role_binding_test.yaml
 PASS  Test Operator ClusterRole        helm/flink-kubernetes-operator/tests/rbac/cluster_role_test.yaml
 PASS  Test Operator RoleBinding        helm/flink-kubernetes-operator/tests/rbac/role_binding_test.yaml
 PASS  Test Operator Role       helm/flink-kubernetes-operator/tests/rbac/role_test.yaml
 PASS  Test MutatingWebhookConfiguration        helm/flink-kubernetes-operator/tests/webhook/mutating_webhook_configuration_test.yaml
 PASS  Test Webhook Secret      helm/flink-kubernetes-operator/tests/webhook/secret_test.yaml
 PASS  Test Webhook Service     helm/flink-kubernetes-operator/tests/webhook/service_test.yaml
 PASS  Test ValidatingWebhookConfiguration      helm/flink-kubernetes-operator/tests/webhook/validating_webhook_configuratioin_test.yaml

Charts:      1 passed, 1 total
Test Suites: 14 passed, 14 total
Tests:       52 passed, 52 total
Snapshot:    0 passed, 0 total
Time:        321.49ms

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changes to the CustomResourceDescriptors: (no)
  • Core observer or reconciler logic that is regularly executed: (no)

Documentation

  • Does this pull request introduce a new feature? (yes)
  • If yes, how is the feature documented? (not documented)

@ChenYi015 ChenYi015 force-pushed the feature/helm-unittest branch from 545ca1a to f8507c6 Compare April 14, 2025 07:25
@gyfora
Copy link
Contributor

gyfora commented Apr 28, 2025

Why did you refactor the helm chart? Is that necessary for the tests to be added?

@ChenYi015
Copy link
Author

Why did you refactor the helm chart? Is that necessary for the tests to be added?

It is not strictly really necessary, but refactoring it would make it easier to write Helm unit tests. If each template file contains only one resource, there will be no need to select the document to test from a multi-document YAML file.

@gyfora
Copy link
Contributor

gyfora commented Apr 28, 2025

Makes sense, would it be possible to integrate the helm test into the maven build or at least the GitHub CI?

Copy link
Contributor

@gyfora gyfora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a good way to compare and make sure that the helm chart did not change before and after the refactor?

@ChenYi015
Copy link
Author

Makes sense, would it be possible to integrate the helm test into the maven build or at least the GitHub CI?

Have raised PR #974 to add Helm lint and tests to the CI.

@gyfora
Copy link
Contributor

gyfora commented Apr 28, 2025

Makes sense, would it be possible to integrate the helm test into the maven build or at least the GitHub CI?

Have raised PR #974 to add Helm lint and tests to the CI.

Please include that commit in this PR so we can test together

@gyfora
Copy link
Contributor

gyfora commented Apr 30, 2025

Could you please rebase on the latest (minor) helm chart changes? Also please provide some comment / proof to show that the helm chart did not change during the refactoring that would speed up the review and we can merge it faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants